package com.itheima;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan("com.itheima.mapper")
public class MybatisPlusStartApplication {
    public static void main(String[] args) {
        SpringApplication.run(MybatisPlusStartApplication.class, args);
    }

//    创建拦截器，并且将分页拦截器加入使用
    //使用
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        //创建分页拦截器：PaginationInnerInterceptor，同时指定数据类型
        //addInnerInterceptor：将分页拦截器加入到拦截器栈，让他生效
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return  mybatisPlusInterceptor;
    }

}
